package com.ruoyi.gpt.domain;

import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
import java.math.BigDecimal;

import com.ruoyi.common.core.domain.BaseEntity;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.util.WxMpConfigStorageHolder;

/**
 * 微信消息对象 f_wx_msg
 *
 * @author ztx
 * @date 2023-03-17
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("f_wx_msg")
public class WxMsg extends BaseEntity {

    private static final long serialVersionUID=1L;

    /**
     * 主键
     */
    @TableId(value = "id")
    private Long id;
    /**
     * appid
     */
    private String appid;
    /**
     * 微信用户ID
     */
    private String openid;
    /**
     * 消息方向
     */
    private String inOut;
    /**
     * 消息类型
     */
    private String msgType;
    /**
     * 消息详情
     */
    private String detail;
    /**
     * 回复的消息内容，仅in_out 为0时可以用
     */
    private String repContent;
    /**
     * 用户id
     */
    private Long userId;
    /**
     * 响应时间
     */
    private String responseTime;
    /**
     * 是否显示0不显示，1显示
     */
    private String isShow;
    /**
     * 备注
     */
    private String remark;
    public WxMsg() {
    }
    public static class WxMsgInOut{
        static final String IN="0";
        static final String OUT="1";
    }


    public static WxMsg buildOutMsg(String msgType, String openid, JSONObject detail){
        WxMsg wxMsg = new WxMsg();
        wxMsg.appid= WxMpConfigStorageHolder.get();
        wxMsg.msgType = msgType;
        wxMsg.openid = openid;
        wxMsg.detail = String.valueOf(detail);
        wxMsg.inOut = WxMsgInOut.OUT;
        return wxMsg;
    }
}
